// Created by Altium Limited 2013
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using DXP;
using EDP;

// The addon server methods and fields are inherited from the
namespace CSharpPlugin
{
    public interface IPluginFactory
    {
        object InvokePluginFactory(IClient a);
    }

    [ClassInterface(ClassInterfaceType.None)]
    public class PluginFactory : IPluginFactory
    {
        public object InvokePluginFactory(IClient a)
        {
            CAddOnCompleteServerModule serverModule = new CAddOnCompleteServerModule(a, "MechLayersMap");
            return serverModule;
        }
    }

    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    public partial class CAddOnCompleteServerModule : ServerModule
    {
        public CAddOnCompleteServerModule(IClient argClient, string argName)
            : base(argClient, argName)
        {
        }

        protected override void InitializeCommands()
        {
            ((CommandLauncher)CommandLauncher).RegisterCommand("Map", this.CommandMap);
        }

        // For addon servers, there is no need to create documents.
        protected override IServerDocument NewDocumentInstance(string argKind, string argFileName)
        {
            return null;
        }


        private void CommandMap(IServerDocumentView argView, ref string argParameters)
        {
            new Commands().CommandMap(argView, argParameters);
        }
    }
}